﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TransformCommand : BaseCommand
{

    private Transform target;
    private Vector3 position;
    private Vector3 eulerAngles;
    private Vector3 scale;
    private Transform parent;

    public TransformCommand(string describe, Transform target) : base(describe)
    {
        this.target = target;
    }

    /// <summary>
    /// 执行
    /// </summary>
    public override void Execute()
    {
        this.position = target.localPosition;
        this.eulerAngles = target.localEulerAngles;
        this.scale = target.localScale;
        this.parent = target.parent;
    }

    /// <summary>
    /// 撤销
    /// </summary>
    public override void Revoke()
    {
        target.SetParent(parent);
        target.localPosition = position;
        target.localEulerAngles = eulerAngles;
        target.localScale = scale;
    }

}

